<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>社矫-职业技能tab页</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css" />
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/webjars/miniui/css/demo.css" rel="stylesheet" type="text/css" />
    <link href="/static/css/default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="mini-fit">
    <form id="form3" method="post">
        <input name="priNum" id="priNum" class="mini-hidden" value="${priNum!''}" readonly />
        <span style="font-size:16px; font-family: 宋体;line-height: 40px;font-weight: bold">职业技能信息:</span>
        <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
            <table style="width:80%;">
                <tr>
                    <td style="width:100%;">
                        <a class="mini-button" id="addbtn" iconCls="fa fa-plus" onclick="addZyjn()">增加</a>
                        <a class="mini-button" id="editbtn" iconCls="fa fa-plus" onclick="editZyjn()">编辑</a>
                        <a class="mini-button" id="delbtn" iconCls="fa-trash-o" onclick="removeZyjn()">删除</a>
                    </td>
                </tr>
            </table>
        </div>
        <div id="grid3" class="mini-datagrid" style="width:100%;height:700px;" sizeList="[5,10,20,30,40,50]"
             pageSize="5"
             url="/azbj/yazgl/xxbl/zyjn/list?1=1&priNum=${priNum!''}" idField="id" selectOnLoad="true">
            <div property="columns">
                <div field="zyjn" width="10" headerAlign="center" align="center">职业技能</div>
                <div field="certName" width="10" headerAlign="center" align="center">证书名称</div>
                <div field="createTime" width="10" renderer="ondayRenderer" headerAlign="center" align="center">录入时间</div>
            </div>
        </div>
    </form>
</div>
</div>
<script type="text/javascript">
    mini.parse();
    var grid3 = mini.get("grid3");
    var priNum = mini.get("priNum");
    grid3.load();

    function addZyjn() {
        mini.open({
            url: "/azbj/yazgl/xxbl/zyjn/add?1=1" + "&priNum=${priNum!''}",
            title: "录入职业技能信息",
            width: 700,
            height: 400,
            onload: function () {
            },
            ondestroy: function (action) {
                grid3.reload();
            }
        });
    }

    function editZyjn() {
        var row = grid3.getSelected();
        if (row) {
            mini.open({
                url: "/azbj/yazgl/xxbl/zyjn/edit?1=1&id=" + row.id,
                title: "编辑职业技能信息", width: 700, height: 400,
                onload: function () {
                },
                ondestroy: function (action) {
                    grid3.reload();
                }
            });
        } else {
            mini.alert("请选中一条记录");
        }
    }

    function removeZyjn() {
        var row = grid3.getSelected();
        var url = "/azbj/yazgl/xxbl/zyjn/remove?1=1&id=" + row.id;
        if (row) {
            mini.confirm("确定删除选中记录？",
                "确定？",
                function (action) {
                    if (action == "ok") {
                        $.ajax({
                            url: url,
                            type: 'POST',
                            cache: false,
                            async: false,
                            success: function (text) {
                                mini.alert("操作成功!");
                                grid3.reload();
                            }, error: function () {
                                mini.alert("操作失败!");
                            }
                        });
                    }
                });
        } else {
            mini.alert("请选中一条记录");
        }
    }

    /**
     * 格式化时间字符串
     * @param e
     * @returns {string}
     */
    function ondayRenderer(e) {
        var value = new Date(e.value);
        if (value) return mini.formatDate(value, "yyyy-MM-dd HH:mm:ss");
    }

    window.onload = function () {
        priNum.setValue(${priNum!''});
        var addbtn = mini.get("addbtn");
        var editbtn = mini.get("editbtn");
        var delbtn = mini.get("delbtn");
        if (priNum.getValue() == "") {
            addbtn.disable();
            editbtn.disable();
            delbtn.disable();
            mini.alert("请先保存基本信息");
        } else {
            addbtn.enable();
            editbtn.enable();
            delbtn.enable();
        }
    }
</script>
</body>
</html>